<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="zh-cn">
    <head>
        <!-- Bootstrap -->
        <include file="Include/css" />
        <title>中经汇通-首页</title>
        <link href="__STATICS__/css/admin/index.css" rel="stylesheet">
        <link href="__STATICS__/css/sweet-alert.css" rel="stylesheet">
        <script type="text/javascript" src="__STATICS__/js/sweet-alert.min.js"></script>

    </head>
    <body>
        <include file="Include/nav_top" />
        <div class="container clearfix" id="left_menu_wraper" >
            <include  file="Include/menu_left" />
            <div id="right-content">
                <div id="right-content-inner">
                    <ul class="breadcrumb">
                        <span>您的位置：</span>
                        <li><a href="{:U('CNEPAdmin/Index/index')}">首页</a> </li>
                        <li class="">广告管理</li>
                        <li class="active">广告位列表</li>
                    </ul>

                    <div id="message_wraper" style="display: none;"  class="alert alert-danger  alert-dismissible" role="alert">

                        <!--关闭按钮-->
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <!--内容-->

                        <strong>温馨提示：</strong> <span id="message" >{$lastsql}</span>
                    </div>
                    <p>
                        <button id="add_look" class="btn btn-orange" type="button" >
                            添加广告图
                        </button>
                    </p>
					<div class="row clearfix margin10 form-horizontal">
                                    <form  name="query" method="POST" >
                                        <span class="pull-left ml30 form_bar">搜索条件：</span>
                                        <div class="col-md-2">
                                            <select  name="sType" class="pull-left ml10 form-control" >
                                                <option value="-1" <eq name="Think.request.sType" value="-1" > selected </eq> >-类型-</option>
                                                <option value="indexslide" <eq name="Think.request.sType" value="indexslide" > selected </eq> >首页轮播广告</option>
                                                <option value="indexad" <eq name="Think.request.sType" value="indexad" > selected </eq> >首页广告</option>
                                                <option value="activityad" <eq name="Think.request.sType" value="activityad" > selected </eq> >活动页广告</option>
												<option value="bankad" <eq name="Think.request.sType" value="bankad" > selected </eq> >银行专区广告</option>
												<option value="ispad" <eq name="Think.request.sType" value="ispad" > selected </eq> >电信运营商广告</option>
                                            </select>
                                        </div>
                                        <button type="submit" class="pull-left btn btn-default ml20">
                                            搜索
                                        </button>
                                    </form>
                                    
                                </div>

                    <div role="tabpanel">

                        <table class="table table-striped table_qrcode table-hover">
                            <!--<caption>标题</caption>-->
                            <thead>
                                <tr class="border">
                                    <th>编号</th>
                                    <th>标题</th>
                                    <th>显示顺序</th>
                                    <th>广告图片</th>
									<th>类型</th>
                                    <th>跳转类型</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <volist name="list" id="vo">
                                    <tr class="qr_tar">
                                        <td>{$vo.imgID}</td>
                                        <td class="list_title">{$vo.title}</td>
                                        <td class="list_index">{$vo.index}</td>
                                        <td class="list_img"><img src="{$imgDomain}{$vo.imgPath}" data-thumb="{$imgDomain}{$vo.thumb}" width="226px" height="138px" ></img></td>
                                        <td class="list_type" data-type="{$vo['type']}">
                                            <eq name="vo['type']" value="indexslide" >首页轮播广告</eq>
                                            <eq name="vo['type']" value="indexad" >首页广告</eq>
                                            <eq name="vo['type']" value="activityad" >活动页广告</eq>
											<eq name="vo['type']" value="bankad" >银行专区广告</eq>
											<eq name="vo['type']" value="ispad" >电信运营商广告</eq>
                                        </td>
										<td data-jump="{$vo['jumpType']}" class="list_jump" data-shop="{$vo['shopID']}" data-url="{$vo['jumpUrl']}" data-goods="{$vo['goodsID']}" data-module="{$vo['moduleID']}" data-material="{$vo['materialID']}">
                                            <eq name="vo['jumpType']" value="no" >无跳转</eq>
                                            <eq name="vo['jumpType']" value="url" >跳转至链接</eq>
                                            <eq name="vo['jumpType']" value="goods" >跳转至商品</eq>
                                            <eq name="vo['jumpType']" value="shop" >跳转至商家</eq>
											<eq name="vo['jumpType']" value="module" >跳转至模块</eq>
											<eq name="vo['jumpType']" value="material" >跳转至素材</eq>
                                        </td>
                                        <td data-id="{$vo.imgID}" ><a href="javascript:void(0)" class="edit_look" >编辑</a> 
                                            /
                                            <a href="javascript:void(0)" class="tar_delete"  >删除</a> </td>
                                    </tr>
                                </volist>
                            </tbody>
                        </table>

                        <div class="clearfix s_page pull-right">
                            {$page}
                        </div>

                    </div>

                </div>

            </div>
        </div>

        <!-- Modal -->
<div class="modal fade bs-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel"> </h4>
      </div>
      <div class="modal-body">
          
            <div class="row clearfix">
                    <div class="col-md-12 margin10">
                                    <div class="col-md-2 text_right form_bar">
                                            标题：
                                    </div>
                                    <div class="col-md-6">
                                        <input id="title" type="text" class="form-control"/>
                                    </div>
                                    <div class="col-md-1 text_warning text_left form_bar">
                                                    *
                                    </div>
                    </div>
					
					<div class="col-md-12 margin10">
                            <div class="col-md-2 text_right form_bar">
                                    类型：
                            </div>
                            <div class="col-md-6">
					<select name="" id="type" class="form-control">
					<option value="indexslide">首页轮播广告</option>
					<option value="indexad">首页广告</option>
					<option value="activityad">活动页广告</option>
					<option value="bankad">银行专区广告</option>
					<option value="ispad">电信运营商广告</option>
                                        </select>
                            </div>
                            <div class="col-md-1 text_warning text_left form_bar">
                                    *
                            </div>
                    </div>
					
					
                    <div class="col-md-12 margin10">
                            <div class="col-md-2 text_right form_bar">
                                    跳转类型：
                            </div>
                            <div class="col-md-6">
					<select name="" id="jumpType" class="form-control">
					<option value="no">无跳转</option>
					<option value="url">跳转至链接</option>
					<option value="goods">跳转至商品</option>
					<option value="shop">跳转至商家</option>
					<option value="module">跳转至模块</option>
					<option value="material">跳转至素材</option>
                                        </select>
                            </div>
                            <div class="col-md-1 text_warning text_left form_bar">
                                    *
                            </div>
                    </div>
                <div id="jump_div" class="col-md-12 margin10">
                        <div id="jump_tip" class="col-md-2 text_right form_bar">
                                    
                            </div>
                            <div class="col-md-6" id="jump_to_div">
                                <input id="jump_to" disabled="disabled" placeholder="" type="text" class="form-control"/>
                            </div>
                </div>
                
                    <div class="col-md-12 margin10">
                            <div class="col-md-2 text_right form_bar">
                                    播放顺序：
                            </div>
                            <div class="col-md-6">
                                <input id="index" type="text" class="form-control"/>
                            </div>
                    </div>
                    <div class="col-md-12 margin10" >
                        <div class="col-md-2 text_right form_bar imgtitle">
                                广告图片：(请上传640*220的图片)
                        </div>
                        <div class="col-md-4">
                            <div class=" padding0 margin10">
                                <div class="upload_wraper dash" style="width: 610px;height: 200px;">
                                    <div class="logo_wraper ">
                                        <img id="pic"  src="{$showPic}" 
                                             class="width100 img-rounded" alt="">
                                        <input type="file" class="input_file" id="fileupload" name="file" value="" data-url="" multiple="">
                                    </div>
                                </div>
                            </div>
                        </div>                                                                                              

                    </div>

            </div>

          <input type="hidden" id="imgPath" value="" />
          <input type="hidden" id="thumb" value="" />
          <input type="hidden" id="imgID" value="" />
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary" id="save" >保存</button>
      </div>
    </div>
  </div>
</div>

        <include file="Include/script" />
        <script src="__STATICS__/js/jquery.ui.widget.js"></script>
        <script src="__STATICS__/js/jquery.iframe-transport.js"></script>
        <script src="__STATICS__/js/jquery.fileupload.js"></script>
        <script src="__STATICS__/js/jquery-form.js"></script>
        
        <script src="__STATICS__/js/admin/hzAjax.js" type="text/javascript"></script>
        <script type="text/javascript" src="__STATICS__/js/admin/shopMsg.js"></script>
        
        <script>
            var isReload = false; // 标识弹出框关闭之后是否刷新页面
            var statics_url = "__STATICS__";
            var headImgUrl = "{:U('CNEPAdmin/Upload/uploadImg',array('pathType'=>0))}";
            
            /*菜单展开及高亮*/
            $(function () {
                $('.slideImg').addClass('open');
                $('#slideImg1').addClass('active');
                
                upload_img(headImgUrl,'fileupload','pic','imgPath','thumb');// 上传图片
                
                 /*弹出框隐藏后*/
                $('#myModal').on('hidden.bs.modal', function (e) {
                     reset_display();
                })
                
                $("#add_look").on("click",function() {
                	$("#myModalLabel").html("添加广告图");
                    $('#myModal').modal(); // 跳出弹窗
                });
                $(".edit_look").on("click",function() {
                      var self = $(this);
                      
                        
                       var title=self.closest('tr').find('.list_title').html();
					   var type=self.closest('tr').find('.list_type').attr("data-type");
                       var index=self.closest('tr').find('.list_index').html();
                       var img=self.closest('tr').find('.list_img img').attr("src");
                       var imgThumb=self.closest('tr').find('.list_img img').attr("data-thumb");
                       var jump=self.closest('tr').find('.list_jump').attr("data-jump");
                       var jumpToUrl=self.closest('tr').find('.list_jump').attr("data-url");
                       var jumpToShop=self.closest('tr').find('.list_jump').attr("data-shop");
                       var jumpToGoods=self.closest('tr').find('.list_jump').attr("data-goods");
					   var jumpToModule=self.closest('tr').find('.list_jump').attr("data-module");
					   var jumpToMaterial=self.closest('tr').find('.list_jump').attr("data-material");
                       var id=self.parent("td").attr("data-id");
                                              
                       $("#title").val(title);
					   $("#type").val(type);
                       $("#jumpType").val(jump);
                       $("#index").val(index);
                       $("#pic").attr("src",img);
                       $("#imgPath").val(img);
                       $("#thumb").val(imgThumb);
                       $("#imgID").val(id);
                       
                       changJumpType();
                       if(jump=="url"){
                    	   $("#jump_to").val(jumpToUrl);
                       }
                       else if(jump=="shop"){
                    	   $("#jump_to").val(jumpToShop);
                       }else if(jump=="goods"){
                    	   $("#jump_to").val(jumpToGoods);
                       } else if(jump=="module"){
							//$("#jump_to_div").html('<select id="jump_to"><option value="1">我要加油</option><option value="2">我要洗车</option><option value="3">汽车美容</option><option value="4">折扣商城</option><option value="5">Uber专区</option><option value="6">便民服务</option><option value="7">电信运营商</option><option value="8">银行专区</option><option value="9">找代驾</option><option value="10">查违章</option></select>');
							$("#jump_to").val(jumpToModule);
					   } else if(jump=="material"){
                    	   $("#jump_to").val(jumpToMaterial);
                       }
                       
                       
                       
                       $('#myModal').modal(); // 跳出弹窗
                    	
                  
                });
                
                /*保存*/
                $("#save").on("click",function() {
                    /* if(checkValue()) {
                       	
                    } */
                    var jump=$("#jumpType").val();
                    var data= {};
                    data.title=$("#title").val();
					data.type=$("#type").val();
                    data.imgPath=$("#imgPath").val();
                    data.thumb=$("#thumb").val();
                    data.imgID=$("#imgID").val();
                    data.jumpType=$("#jumpType").val();
                    data.index=$("#index").val();
                   
                    
                    
                    if(jump=="url"){
                    	data.jumpUrl=$("#jump_to").val();
                    }
                    else if(jump=="shop"){
                    	data.shopID=$("#jump_to").val();
                    }else if(jump=="goods"){
                    	data.goodsID=$("#jump_to").val();
                    }else if(jump=="module"){
						data.moduleID=$("#jump_to option:selected").val();
					} else if(jump=="material"){
						data.materialID=$("#jump_to").val();
					}
                    
                    if(data.imgID === ""){
                    	ajax_go(data,"{:U('CNEPAdmin/SlideImg/addSlideImg')}",true);
                    }
                    else{
                    	ajax_go(data,"{:U('CNEPAdmin/SlideImg/updateSlideImg')}",true);
                    }
                });
                
                $("#jumpType").on("change",function() {
                	changJumpType();
                });
				
				$("#type").on("change",function() {
                	changtype();
                });
				
				function changtype(){
                	var type = $.trim($("#type").val());
                    if(type == 'indexslide') {
						$('.imgtitle').html('广告图片：(请上传640*220的图片)');
                    }
					else if(type == 'indexad') {
						$('.imgtitle').html('广告图片：(请上传320*148的图片)');
                    }
					else if(type == 'activityad') {
						$('.imgtitle').html('广告图片：(请上传320*148的图片)');
                    }
					else if(type == 'bankad') {
						$('.imgtitle').html('广告图片：(请上传320*148的图片)');
                    }
					else if(type == 'ispad') {
						$('.imgtitle').html('广告图片：(请上传320*148的图片)');
                    }
                }
                
                function changJumpType(){
                	var jumpType = $.trim($("#jumpType").val());
                    if(jumpType === 'no') {
						$("#jump_to_div").html(' <input id="jump_to" disabled="disabled" placeholder="" type="text" class="form-control"/>');
                        $("#jump_to").attr("disabled",true);
                    }else if(jumpType === 'url') {
						$("#jump_to_div").html(' <input id="jump_to" disabled="disabled" placeholder="" type="text" class="form-control"/>');
                        $("#jump_to").attr("disabled",false);
                        $("#jump_to").attr("placeholder","请输入跳转的 URL 地址");
                    }else if(jumpType === 'goods') {
						$("#jump_to_div").html(' <input id="jump_to" disabled="disabled" placeholder="" type="text" class="form-control"/>');
                        $("#jump_to").attr("disabled",false);
                        $("#jump_to").attr("placeholder","请输入跳转商品的ID");
                    }else if(jumpType === 'shop') {
						$("#jump_to_div").html(' <input id="jump_to" disabled="disabled" placeholder="" type="text" class="form-control"/>');
                        $("#jump_to").attr("disabled",false);
                        $("#jump_to").attr("placeholder","请输入跳转的商家的ID");
                    }else if(jumpType === 'module'){
						$("#jump_to_div").html('<select id="jump_to"><option value="1">我要加油</option><option value="2">我要洗车</option><option value="3">汽车美容</option><option value="4">折扣商城</option><option value="5">Uber专区</option><option value="6">便民服务</option><option value="7">电信运营商</option><option value="8">银行专区</option><option value="9">找代驾</option><option value="10">查违章</option><option value="11">油我发起</option><option value="12">我要赚钱</option><option value="13">保险专区</option><option value="14">我要买车</option></select>');
						
					}else if(jumpType === 'material') {
						$("#jump_to_div").html(' <input id="jump_to" disabled="disabled" placeholder="" type="text" class="form-control"/>');
                        $("#jump_to").attr("disabled",false);
                        $("#jump_to").attr("placeholder","请输入跳转素材的ID");
                    }
                }
                
                
                $(".tar_delete").on("click", function () {
                    var self = $(this);
                    swal({   title: "您确定吗?",
                                text: "您将删除此账号！",
                                type: "warning",
                                showCancelButton: true,
                                confirmButtonColor: "#DD6B55",
                                confirmButtonText: "是的，删除",
                                cancelButtonText: "放弃",
                                closeOnConfirm: false
                            },
                            function (isConfirm) {
                                if (isConfirm) {
                                    var ajaxData = {};
                                    ajaxData.imgID = self.parent("td").attr("data-id");
                                    ajax_go(ajaxData ,'{:U("CNEPAdmin/SlideImg/deleteSlideImg")}',true);
                                }

                            });


                });
                
                
            });
            
            function checkValue() {
                swal('ceshi','','warning');
            }
            
            /*清空弹出框内容*/
            function reset_display()
            {
                if(isReload) {
                    window.location.reload();
                }
                
                $("#imgID").val("");
                $("#title").val("");
				$("#type").val("");
                $("#jump_to").val("");
                $("#imgPath").val("");
                $("#thumb").val("");
                $("#index").val("");
                $("#pic").attr("src","");
                $("#role_0").attr("selected",true);

            }
                        
        </script>
    </body>
</html>